package com.lee.thread;

class RunnableDemo extends ThreadRun implements Runnable {
	
	
	Thread thread2 = null;

	public void runDemo(RunnableDemo r1) {
		Thread thread1 = new Thread(r1, "第一线程");
		thread2  = new Thread(r1, "第二线程");
		thread2.start();
		try {
			System.out.println("第一线程开始休眠");
			Thread.sleep(400);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}




	@Override
	public void run() {
		for (int i = 0; i < 800; i += 100) {
			System.out.println(Thread.currentThread().getName()+" 第二线程休眠时间:"+i);
			try {
				thread2.sleep(i);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
	
}

class ThreadRun {
	public  String print() {
		return "父类print方法";
	}
}

public class ThreadTest3 {
	public static void main(String[] args) {
		RunnableDemo r1 = new RunnableDemo();
		r1.runDemo(r1);
		System.out.println(r1.print());
	}
}
